package com.liu.stockmarket.repository.database.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import java.math.BigDecimal
import java.time.LocalDate
import java.time.LocalDateTime

/**
 * 交易记录
 */

@Entity(tableName = "transaction_record")
data class TransactionRecordEntity(
    @PrimaryKey(autoGenerate = true)
    val id: Long?=null,
    /**
     * 股票id
     */
    @ColumnInfo(name = "stock_id")
    val stockId: Long,

    /**
     * 交易类型
     */
    @ColumnInfo(name = "transaction_type")
    val transactionType: TransactionType,

    /**
     * 交易时间
     */
    @ColumnInfo(name = "transaction_date")
    val transactionDate: LocalDate,


    /**
     * 交易单价
     */
    @ColumnInfo(name = "transaction_price")
    val transactionPrice: BigDecimal,

    /**
     * 交易数量
     */
    @ColumnInfo(name = "transaction_number")
    val transactionNumber: BigDecimal,


    /**
     * 手续费
     */
    @ColumnInfo(name = "handling_fee")
    val handlingFee:BigDecimal,


    /**
     * 更新时间
     */
    @ColumnInfo(name = "update_datetime")
    val updateDateTime: LocalDateTime? = LocalDateTime.now(),

    /**
     * 添加时间
     */
    @ColumnInfo(name = "create_datetime")
    val createDateTime: LocalDateTime? = LocalDateTime.now(),

    ) {
    enum class TransactionType(val aliasName: String) {
        BUY("买入"),
        SELL("卖出"),
        DIVIDENDS("分红")
    }

}